import { orderPage } from '../../../api/cert'

Page({
  data: {
    list: [],
    isEnd: false,
    listQuery: {
      condition: {},
      pager: {
        page: 1,
        pageSize: 10
      }
    }
  },

  onLoad: function (options) {
    this.init()
  },
  init() {
    this.getList()
  },
  getList() {
    if (!this.data.isEnd) {
      orderPage(this.data.listQuery).then(res => {
        let list = this.data.list
        list = list.concat(res.records)
        this.setData({
          list: list
        })
        if (res.records.length < 10) {
          this.setData({
            isEnd: true
          })
        }
      })
    }
    this.setData({
      list: list
    })
  },
  toLower() {
    const page = this.data.pager.page++
    this.setData({
      'listQuery.pager.page': page
    })
    this.getList()
  }
})
